(function(angular) {
	"use strict";
	angular.module("fs.waf").factory("settlementInitDefaultService", settlementInitDefaultService);
	settlementInitDefaultService.$inject = [ "setlDetailService", "$q" ];
	function settlementInitDefaultService(setlDetailService, $q) {

		function changeAmountBox(settlement, setlDetail) {
			var amt = setlDetailService.calculatePayAmt(settlement.site, setlDetail);
			setlDetail.payAmt = amt;
			payDetailService.changePaydetailBySetldetail(settlement, setlDetail);
		}
		
		function getBackMessage() {
			return "title.infobar.settlementinit.back";
		}
		
		function getLayout(settlement, packageSuffix) {
			return $q(function(resolved, rejected) {
				resolved(undefined);
			});
		}
		
		function getGeneralConfig(layoutConfig) {
			return angular.copy(layoutConfig.formConfigs.general);
		}
		
		function getGeneralModel(settlement) {
			return settlement.loan;
		}
		
		function processDynaparmConfig(loyout){
			angular.forEach(loyout.formConfigs.general.gridConfigs, function(gridConfig){
				if(gridConfig.model.indexOf("dynamicParams.") != -1){
					gridConfig.model = "loan." + gridConfig.model;
				}
			});
		}

		return {
			changeAmountBox : changeAmountBox,
			getBackMessage : getBackMessage,
			getLayout : getLayout,
			getGeneralConfig : getGeneralConfig,
			getGeneralModel : getGeneralModel,
			processDynaparmConfig : processDynaparmConfig
		};
	}
})(angular);
